package assignment;

public class test2 {
    public final static int INFINITY = Integer.MAX_VALUE;
    Object vexs[] = { "二食堂", "办公楼","教学楼","一舍", "十舍", "图书馆","体育馆" ,"大门"};
    int[][] arce = { { 0, INFINITY,INFINITY, 15,30,INFINITY,10 },
                     { INFINITY, 0, INFINITY, INFINITY ,4,4,INFINITY}, 
                     { INFINITY,INFINITY,0,4, INFINITY, 6,INFINITY },
                     { 15, INFINITY,4,0, INFINITY,INFINITY, 20 }, 
                     {INFINITY,4,INFINITY,INFINITY,0,12,8},
                     {INFINITY,4,6,INFINITY,12,0,INFINITY},
                     {10,INFINITY,INFINITY,20,8,INFINITY,0}};
    ShortestPath_FLOYD floyd = new ShortestPath_FLOYD();
	public Object m;
    public  void findPlace() throws Exception { 
        MGraph G = new MGraph(GraphKind.UDG, 7, 9, vexs, arce);
        floyd.floyd(G);
        int[][] D=floyd.getD();
        int min = INFINITY;
        int sum = 0;
        int u = -1;
        int d = D.length;
        for (int v = 0; v < d; v++) {
            sum = 0;
            for (int w = 0; w < d; w++)
                sum += D[v][w]; // 求一点到其他顶点的最短长度之和
            if (min > sum) {
                min = sum;
                u = v;
            }
        }
        m=G.getVex(u);
    }
}
